/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.games.epkb.entityClasses;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author plebani
 */
@Entity
@Table(name = "cpu_core")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CpuCore.findAll", query = "SELECT c FROM CpuCore c"),
    @NamedQuery(name = "CpuCore.findById", query = "SELECT c FROM CpuCore c WHERE c.id = :id"),
    @NamedQuery(name = "CpuCore.findByMode", query = "SELECT c FROM CpuCore c WHERE c.mode = :mode"),
    @NamedQuery(name = "CpuCore.findByCurrentFrequency", query = "SELECT c FROM CpuCore c WHERE c.currentFrequency = :currentFrequency")})
public class CpuCore implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID")
    private String id;
    @Column(name = "Mode")
    private String mode;
    @Column(name = "CurrentFrequency")
    private String currentFrequency;
    @OneToMany(mappedBy = "idCore")
    private Collection<CpuCorePower> cpuCorePowerCollection;
    @JoinColumn(name = "Id_CPU", referencedColumnName = "ID")
    @ManyToOne
    private Cpu idCPU;
    @JoinColumn(name = "ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Component component;

    public CpuCore() {
    }

    public CpuCore(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }

    public String getCurrentFrequency() {
        return currentFrequency;
    }

    public void setCurrentFrequency(String currentFrequency) {
        this.currentFrequency = currentFrequency;
    }

    @XmlTransient
    public Collection<CpuCorePower> getCpuCorePowerCollection() {
        return cpuCorePowerCollection;
    }

    public void setCpuCorePowerCollection(Collection<CpuCorePower> cpuCorePowerCollection) {
        this.cpuCorePowerCollection = cpuCorePowerCollection;
    }

    public Cpu getIdCPU() {
        return idCPU;
    }

    public void setIdCPU(Cpu idCPU) {
        this.idCPU = idCPU;
    }

    public Component getComponent() {
        return component;
    }

    public void setComponent(Component component) {
        this.component = component;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CpuCore)) {
            return false;
        }
        CpuCore other = (CpuCore) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "it.polimi.games.epkb.entityClasses.CpuCore[ id=" + id + " ]";
    }
    
}
